package behavioral_pattern. mediator_pattern;

/**
 * 中介者
 * 定义：用一个中介对象来封装一些列的对象交互，中介者使各对象不需要显式地相互调用，
 * 从而使其耦合松散，而且可以独立地改变他们之间的交互。
 */

public class MainMediator {
    public static void main(String[] args) {
        ConcreteMediator mediator;
        mediator = new ConcreteMediator();

        Button addBt = new Button();
        List list = new List();
        ComboBox comboBox = new ComboBox();
        TextBox userNameTb = new TextBox();


        addBt.setMediator(mediator);
        list.setMediator(mediator);
        comboBox.setMediator(mediator);
        userNameTb.setMediator(mediator);

        mediator.addButton = addBt;
        mediator.list = list;
        mediator.comboBox = comboBox;
        mediator.userNameTextBox = userNameTb;

        addBt.change();
        System.out.println("------------------");
        list.change();
    }
}
